package com.sc.justification;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import com.sc.justification.business.ListPanel;
import com.sc.justification.model.Menu;
import com.sc.justification.system.InitDialog;
import com.sc.justification.system.SetupDialog;
@SuppressWarnings("all")
public class ActionBuilder {
	public static Action getAction(Menu menu){
		Action action=null;
		if("xtcsh".equals(menu.getAction())){
			action= new AbstractAction() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					EventQueue.invokeLater(new Runnable() {
						@Override
						public void run() {
							InitDialog dialog=new InitDialog();
							dialog.setLocationRelativeTo(AppWindow.frame);
							dialog.setVisible(true);
						
						}
						
					});
				}
			};
		}
		else if("xtsz".equals(menu.getAction())){
			action= new AbstractAction() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					EventQueue.invokeLater(new Runnable() {

						@Override
						public void run() {
							SetupDialog dialog=new SetupDialog();
							dialog.setLocationRelativeTo(AppWindow.frame);
							dialog.setVisible(true);
						
						}
						
					});
				}
			};
		}
		else if("jdzx".equals(menu.getAction())){
			action= new AbstractAction() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					EventQueue.invokeLater(new Runnable() {

						@Override
						public void run() {
							ListPanel listPanel=new ListPanel();
							AppWindow.splitPane.setRightComponent(listPanel);
							
						}
						
					});
				}
			};
		}
		if(action!=null)action.putValue(Action.NAME, menu.getName());
		return action;
	}
}
